package com.navinfo.opentsp.platform.computing.dto;


import com.navinfo.opentsp.platform.location.protocol.common.LCFaultInfo;

import java.util.ArrayList;
import java.util.List;

public class FaultInfoDto {

    private Integer faultType;
    private Integer subSpeed;
    private Integer accelerator;
    private Integer brakeSignal;
    private Integer rotation;
    private Integer engineTurbochargedPressure;
    private Integer engineIntakePressure;
    private Integer engineExhaustTemperature;
    private Integer engineCoolantTemperature;
    private Integer accelerationRate;
    private Integer gear;
    private Integer engineOutputTorque;
    private Long load;
    private Integer engineLoad;
    private Integer vehicleAcceleration;
    private Integer vehicleSpeedReduction;
    private Integer faultCodeCount;
    private List<FaultItem> faultItemList;

    public FaultInfoDto() {
    }

    public Integer getFaultType() {
        return faultType;
    }

    public void setFaultType(Integer faultType) {
        this.faultType = faultType;
    }

    public Integer getSubSpeed() {
        return subSpeed;
    }

    public void setSubSpeed(Integer subSpeed) {
        this.subSpeed = subSpeed;
    }

    public Integer getAccelerator() {
        return accelerator;
    }

    public void setAccelerator(Integer accelerator) {
        this.accelerator = accelerator;
    }

    public Integer getBrakeSignal() {
        return brakeSignal;
    }

    public void setBrakeSignal(Integer brakeSignal) {
        this.brakeSignal = brakeSignal;
    }

    public Integer getRotation() {
        return rotation;
    }

    public void setRotation(Integer rotation) {
        this.rotation = rotation;
    }

    public Integer getEngineTurbochargedPressure() {
        return engineTurbochargedPressure;
    }

    public void setEngineTurbochargedPressure(Integer engineTurbochargedPressure) {
        this.engineTurbochargedPressure = engineTurbochargedPressure;
    }

    public Integer getEngineIntakePressure() {
        return engineIntakePressure;
    }

    public void setEngineIntakePressure(Integer engineIntakePressure) {
        this.engineIntakePressure = engineIntakePressure;
    }

    public Integer getEngineExhaustTemperature() {
        return engineExhaustTemperature;
    }

    public void setEngineExhaustTemperature(Integer engineExhaustTemperature) {
        this.engineExhaustTemperature = engineExhaustTemperature;
    }

    public Integer getEngineCoolantTemperature() {
        return engineCoolantTemperature;
    }

    public void setEngineCoolantTemperature(Integer engineCoolantTemperature) {
        this.engineCoolantTemperature = engineCoolantTemperature;
    }

    public Integer getAccelerationRate() {
        return accelerationRate;
    }

    public void setAccelerationRate(Integer accelerationRate) {
        this.accelerationRate = accelerationRate;
    }

    public Integer getGear() {
        return gear;
    }

    public void setGear(Integer gear) {
        this.gear = gear;
    }

    public Integer getEngineOutputTorque() {
        return engineOutputTorque;
    }

    public void setEngineOutputTorque(Integer engineOutputTorque) {
        this.engineOutputTorque = engineOutputTorque;
    }

    public Long getLoad() {
        return load;
    }

    public void setLoad(Long load) {
        this.load = load;
    }

    public Integer getEngineLoad() {
        return engineLoad;
    }

    public void setEngineLoad(Integer engineLoad) {
        this.engineLoad = engineLoad;
    }

    public Integer getVehicleAcceleration() {
        return vehicleAcceleration;
    }

    public void setVehicleAcceleration(Integer vehicleAcceleration) {
        this.vehicleAcceleration = vehicleAcceleration;
    }

    public Integer getVehicleSpeedReduction() {
        return vehicleSpeedReduction;
    }

    public void setVehicleSpeedReduction(Integer vehicleSpeedReduction) {
        this.vehicleSpeedReduction = vehicleSpeedReduction;
    }

    public Integer getFaultCodeCount() {
        return faultCodeCount;
    }

    public void setFaultCodeCount(Integer faultCodeCount) {
        this.faultCodeCount = faultCodeCount;
    }

    public List<FaultItem> getFaultItemList() {
        return faultItemList;
    }

    public void setFaultItemList(List<FaultItem> faultItemList) {
        this.faultItemList = faultItemList;
    }

    public static FaultInfoDto protoToBean(LCFaultInfo.FaultListData faultListData){
        FaultInfoDto faultInfoDto = new FaultInfoDto();
        faultInfoDto.setFaultType(faultListData.getFaultType());
        List<FaultItem> faultItemList = new ArrayList<>();
        for(LCFaultInfo.FaultItem item : faultListData.getFaultItemList()){
            FaultItem faultItem = new FaultItem();
            faultItem.setFaultAddr(item.getFaultAddr());
            faultItem.setFMI(item.getFMI());
            faultItem.setSPN(item.getSPN());
            faultItemList.add(faultItem);
        }
        faultInfoDto.setFaultItemList(faultItemList);
        faultInfoDto.setAccelerationRate(faultListData.getAccelerationRate());
        faultInfoDto.setAccelerator(faultListData.getAccelerator());
        faultInfoDto.setBrakeSignal(faultListData.getBrakeSignal());
        faultInfoDto.setFaultType(faultListData.getFaultType());
        faultInfoDto.setEngineCoolantTemperature(faultListData.getEngineCoolantTemperature());
        faultInfoDto.setEngineExhaustTemperature(faultListData.getEngineExhaustTemperature());
        faultInfoDto.setEngineIntakePressure(faultListData.getEngineIntakePressure());
        faultInfoDto.setEngineOutputTorque(faultListData.getEngineOutputTorque());
        faultInfoDto.setEngineLoad(faultListData.getEngineLoad());
        faultInfoDto.setEngineTurbochargedPressure(faultListData.getEngineTurbochargedPressure());
        faultInfoDto.setFaultCodeCount(faultListData.getFaultCodeCount());
        faultInfoDto.setGear(faultListData.getGear());
        faultInfoDto.setLoad(faultListData.getLoad());
        faultInfoDto.setRotation(faultListData.getRotation());
        faultInfoDto.setSubSpeed(faultListData.getSubSpeed());
        faultInfoDto.setVehicleAcceleration(faultListData.getVehicleAcceleration());
        faultInfoDto.setVehicleSpeedReduction(faultListData.getVehicleSpeedReduction());
        return faultInfoDto;
    }

    public static class FaultItem {
        private int faultAddr;
        private int SPN;
        private int FMI;


        public int getFaultAddr() {
            return faultAddr;
        }

        public void setFaultAddr(int faultAddr) {
            this.faultAddr = faultAddr;
        }

        public int getSPN() {
            return SPN;
        }

        public void setSPN(int SPN) {
            this.SPN = SPN;
        }

        public int getFMI() {
            return FMI;
        }

        public void setFMI(int FMI) {
            this.FMI = FMI;
        }
    }
}
